package Controller.Actions.Delete;

import Controller.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import Model.Beans.Results.*;
import Model.Beans.*;
import Model.QBE.*;

public class DeleteProfessorAction implements Action {
    
    private String name;
    
    public DeleteProfessorAction() 
    {
        this.name = "DeleteProfessor";
    }
    
    public String getName()
    {
        return name;
    }
    
    public void perform(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
        
        response.setContentType("text/xml");
        response.setHeader("Cache-Control", "no-cache");
        ProfessorModel model = new ProfessorModel();
        String id = request.getParameter("id");
        
        Person professor = new Person();
        professor.setId(Integer.parseInt(id));
        
        if(model.delete(professor) != 0)
        {
            response.getWriter().write("<message> The professor has been successfully deleted </message>");
        }
        else
        {
            response.getWriter().write("<message>The ID doesn't exists </message>");
        }
    }
}
